
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.media.*;

/**
 * @author Prin
 */
public class a extends MIDlet implements CommandListener, ItemCommandListener {

    private Display di = Display.getDisplay(this);
    private b bb = new b();
    private c cc = new c();


    private Form form = new Form("Đăng nhập");
    private Form form2;
    private TextField tf1  = new TextField("Tài khoản: ", "", 20, TextField.ANY);
    private TextField tf2  = new TextField("Mật khẩu: ", "", 20, TextField.PASSWORD);
    private Command login  = new Command("Chọn", Command.ITEM, 0);
    private Command reg    = new Command("Chọn", Command.ITEM, 0);
    private Command logout = new Command("Đăng xuất", Command.BACK, 0);
    private Command exit   = new Command("Thoát", Command.EXIT, 0);
    private Command back   = new Command("Trở lại", Command.BACK, 0);
    private StringItem item;
    private StringItem item2;





    public a() {

        form.append(tf1);
        form.append(tf2);
        item = new StringItem("", "Đăng nhập", Item.BUTTON);
        item.setDefaultCommand(login);
        item.setItemCommandListener(this);
        item2= new StringItem("", "Đăng kí", Item.BUTTON);
        item2.setDefaultCommand(reg);
        item2.setItemCommandListener(this);
        form.append(item);
        form.append(item2);
        form.addCommand(exit);

        bb.addCommand(logout);

        form.setCommandListener(this);
        bb.setCommandListener(this);

    }




    public void startApp() {
            di.setCurrent(cc);
        try {
            Thread.sleep(2500);
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        }
            di.setCurrent(form);

            try {
  Player player = Manager.createPlayer(getClass().
  getResourceAsStream("/love.mp3"),"audio/mpeg");


  player.start();
  } catch(Exception e) {
  e.printStackTrace();
  }
            







    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void err() {
        form2 = new Form("Đăng kí");


        form2.addCommand(back);
        form2.setCommandListener(this);
        String msg="Tính năng này chưa được hỗ trợ";
        form2.append(msg);


        form.setCommandListener(this);


        di.setCurrent(form2);


    }

    public void commandAction(Command c, Displayable d) {
        if (c == logout & d == bb) {
            di.setCurrent(form);
        }
        else if (c == back) {
            di.setCurrent(form);
        }

        else if (c == exit) {
            destroyApp(true);
            notifyDestroyed();

        }


    }


    public void commandAction(Command c, Item item) {

        if (c == login) {


            di.setCurrent(bb);



       }

         else if (c == reg) {
           err();
        }




    }


}
